<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<%
	String path = request.getContextPath();
    //用户登陆
    String fphone = (String)request.getParameter("fphone"); 
    
    System.out.println("----------" + fphone);
%>
<title>接收统计</title>
<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/btn_class.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path%>/ext-2.2/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="<%=path%>/ext-2.2/style.css" />
<script type="text/javascript"
	src="<%=path%>/ext-2.2/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="<%=path%>/ext-2.2/ext-all.js"></script>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src = "<%=path%>/FusionCharts/FusionCharts.js"></script>
	<script type="text/javascript" src = "<%=path%>/FusionCharts/FusionChartsExportComponent.js"></script>
	<script type="text/javascript" src="<%=path%>/js/datepicker/WdatePicker.js" defer="defer"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
	
</body>
<script type="text/javascript">
	Ext.BLANK_IMAGE_URL = "<%=path%>/ext-2.2/resources/images/default/s.gif";
	Ext.QuickTips.init();// 为组件提供提示信息功能，form的主要提示信息就是客户端验证的错误信息。
    Ext.form.Field.prototype.msgTarget='side'; 

	var user_phone = '<%=fphone%>';


	Ext.onReady(function() {
				Ext.QuickTips.init();
				
				var Jthtwb = Ext.data.Record.create([ {
					name : 'fpid',
					mapping : 'fpid',
					type : 'string'
				}, {
					name : 'fname',
					mapping : 'fname',
					type : 'string'
				}, {
					name : 'fstate',
					mapping : 'fstate',
					type : 'string'
				}, {
					name : 'fsex',
					mapping : 'fsex',
					type : 'string'
				}, {
					name : 'fphone1',
					mapping : 'fphone1',
					type : 'string'
				}, {
					name : 'fssy',
					mapping : 'fssy',
					type : 'string'
				}, {
					name : 'fszy',
					mapping : 'fszy',
					type : 'string'
				}, {
					name : 'fxl',
					mapping : 'fxl',
					type : 'string'
				}, {
					name : 'fxtnd',
					mapping : 'fxtnd',
					type : 'string'
				}, {
					name : 'fdate',
					mapping : 'fdate',
					type : 'string'
				}, {
					name : 'frdate',
					mapping : 'frdate',
					type : 'string'
				} ]);

				var ds = new Ext.data.Store({
					reader : new Ext.data.JsonReader({
						totalProperty : 'totalProperty',
						root : 'root'
					}, Jthtwb),
					idProperty : 'threadid',
					remoteSort : true,
					url : 'xyj!queryXyjRecord.do'
				});

				ds.load( {
					params : {
						start : 0,
						limit : 50,
						fstate : '0',
						fkeywords : user_phone,
						fbtime : '',
						fetime : new Date().format('Y-m-d'),
						fvalueType : '',
						fvalue1 : '',
						fvalue2 : '',
						ftakeBack : '0'
					}
				});


				//定义勾选框，不需要可不必定义
				var sm = new Ext.grid.CheckboxSelectionModel({
					singleSelect : true //单选
				});

				//定义列
				var colM = new Ext.grid.ColumnModel([ 
				    {
						header : '数据接收日期',
						dataIndex : 'frdate',
						width : 100,
						renderer : function(value) {
								if (value == null || value == "null") {
									return "";
								} else {
									return value;
								}
							}
					}, {
						header : '收缩压',
						dataIndex : 'fssy',
						width : 100,
						renderer : function(value) {
								if (value == null || value == "null") {
									return "";
								} else {
									return value + " /mmHg";
								}
							}
					}, {
						header : '舒张压',
						dataIndex : 'fszy',
						width : 100,
						renderer : function(value) {
								if (value == null || value == "null") {
									return "";
								} else {
									return value + " /mmHg";
								}
							}
					}, {
						header : '心率',
						dataIndex : 'fxl',
						width : 100,
						renderer : function(value) {
								if (value == null || value == "null") {
									return "";
								} else {
									return value + " /min";
								}
							}
					} ]);

				
				//生成表格
				var grid = new Ext.grid.GridPanel({
					closable : false,
					region : 'center',
					height : 350,
					autoWidth : true,
					stripeRows : true,
					//title : '角色列表',
					cm : colM,
					ds : ds,
					sm : sm,
					listeners : {
						'rowdblclick' : function(grid, row) { //双击打开
							var record = grid.getSelectionModel().getSelected();
							if (record) {
								show_chart_fun(record.data.fphone1, record.data.fname);
							}
						}
					},
					bbar : new Ext.PagingToolbar({
				        pageSize: 50,
				        store: ds,
				        displayInfo: true,
				        displayMsg: '共 {2} 条',
				        emptyMsg: "没有记录"
				    })
				});
				
				var detailsPanel = {
					id: 'details-panel',
			        region: 'center',
			        bodyStyle: 'padding-bottom:15px;background:#FFFFFF;',
					autoScroll: true,
					html : '<div bgcolor="#cfdefr" width="100%" height="100%"><table align="crnter">'
			 	
 					+'<tr valign="top"><td align="center" colspan="3" id="chart2102"></td><td width="20"></td><td align="center"></td></tr>'
 					+'<tr valign="top"><td align="center" width="20"></td><td align="left" id="text2102" style="font-size:12px"></td><td align="center" width="20"></td><td width="20"></td><td align="center"></td></tr>'
 					+ '<tr> <td colspan="6" height="15"></td> </tr>'
 					
 					+'<tr valign="top"><td align="center" colspan="3" id="chart2101"></td><td width="20"></td><td align="center" ></td></tr>'
 					+'<tr valign="top"><td align="center" width="20"></td><td align="left" id="text2101" style="font-size:12px"></td><td align="center" width="20"></td><td width="20"></td><td align="center"></td></tr>'
 					+ '<tr> <td colspan="6" height="15"></td> </tr>'
 					
 					+'<tr valign="top"><td align="center" colspan="3" id="chart2104"></td><td width="20"></td><td align="center" ></td></tr>'
 					+'<tr valign="top"><td align="center" width="20"></td><td align="left" id="text2104" style="font-size:12px"></td><td align="center" width="20"></td><td width="20"></td><td align="center"></td></tr>'
 					+ '<tr> <td colspan="6" height="15"></td> </tr>'

					+ '</table></div>'
			    };
			    
				var btn_close = new Ext.Button({
					text : '关闭',
					iconCls : 'sy-reset',
					handler : function() {
						chart_window.close();
					}
				});
				
				var panel_right = new Ext.Panel({
					region: "east",
					split:true,
		            minSize: 105,
		            maxSize: 500,
		            title : '历史数据',
		            collapsible: true,
		            collapsed: true, //展开或关闭
		            margins:'0 0 0 0',
		            layout:'fit',
		            layoutConfig:{
		                animate:true
		            },
					items :[ grid ],
					width:350
			   });
			   
			   
			  var b_date = new Ext.form.TextField({
				fieldLabel : '开始日期',
				format: 'yyyy-MM-dd',
				id:'fbdate_id',
				name:'fbdate',
				width : 100,
				style:"cursor:pointer;color:blue",
				listeners : {
					'focus' : function() {
						WdatePicker({startDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true});
					}
				}
			});
           var e_date = new Ext.form.TextField({
   				fieldLabel : '结束日期',
   				format: 'yyyy-MM-dd',
   				id:'fedate_id',
				name:'fedate',
				width : 100,
				value : new Date().format('Y-m-d'),
   				style:"cursor:pointer;color:blue",
   				listeners : {
   					'focus' : function() {
   						WdatePicker({startDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true});
   					}
   				}
   			});
	   			
	   			var btn_search_chart = new Ext.Button({
					text : '查询',
					iconCls : 'sy-search',
					handler : function(btn) {
						
						var ftjlx = Ext.getCmp("query_type_radio_id").getValue();
						var foffi_type = Ext.get("foffi_type_value").dom.value;
						var fquery_str = "";
						var ftitle = "";
						var fbdate = Ext.get("fbdate_id").dom.value;
						var fedate = Ext.get("fedate_id").dom.value;
						
						if(ftjlx == "2") {
							ftjlx = "q";
						} else {
							ftjlx = "mm";
						}
						
						 //出院患者统计
						 Ext.Ajax.request({     
							 url : 'chartInfo!produceChartDataCommon.do',     
							 method : 'POST',     
							 params : {        
								 'fbdate' : fbdate,
								 'fedate' : fedate,
								 'ftjlx' : ftjlx
								 },     
							 success : function(response, action) {        
								 var myChart;        
								 var data_str = new Array();        
								 var responseText = response.responseText; 
								 
								 data_str = responseText.split('$$');        
								 var chart_data = data_str[0];           
								 myChart = new FusionCharts("${basePath}/FusionCharts/Column2D.swf","chartid2102","1000","300","0","1");        
								 myChart.setDataXML(chart_data); 
								 myChart.render('chart2102');     
								 
								 document.getElementById("text2102").innerHTML = "　　" + data_str[1];
							  },     
							 failure : function() {        
								 Ext.Msg.alert('错误', '服务器出现错误请稍后再试！');     
							 }  
						  });  
						
						 //住院患者死亡人次统计
						Ext.Ajax.request({     
							 url : 'chartInfo!produceChartDataCommon.do',     
							 method : 'POST',     
							 params : {        
								 'fbh' : 'MCD2101',        
								 'fquery_str' : fquery_str,        
								 'ftitle' : ftitle,          
								 'ftype_date' : '1'     
								 },     
							 success : function(response, action) {        
								 var myChart;        
								 var data_str = new Array();        
								 var responseText = response.responseText; 
								 
								 data_str = responseText.split('$$');        
								 var chart_data = data_str[0];           
								 myChart = new FusionCharts("${basePath}/FusionCharts/Line.swf","chartid2101","1000","300","0","1");        
								 myChart.setDataXML(chart_data); 
								 myChart.render('chart2101');     
				
								 document.getElementById("text2101").innerHTML = "　　" + data_str[1];
							 },     
							 failure : function() {        
								 Ext.Msg.alert('错误', '服务器出现错误请稍后再试！');     
							 }  
						  });
						 
						//住院患者死亡人次统计
						Ext.Ajax.request({     
							 url : 'chartInfo!produceChartDataCommon.do',     
							 method : 'POST',     
							 params : {        
								 'fbh' : 'MCD2104',        
								 'fquery_str' : fquery_str,        
								 'ftitle' : ftitle,          
								 'ftype_date' : '1'     
								 },     
							 success : function(response, action) {        
								 var myChart;        
								 var data_str = new Array();        
								 var responseText = response.responseText; 
								 
								 data_str = responseText.split('$$');        
								 var chart_data = data_str[0];           
								 myChart = new FusionCharts("${basePath}/FusionCharts/Column2D.swf","chartid2104","1000","300","0","1");        
								 myChart.setDataXML(chart_data); 
								 myChart.render('chart2104');    
				
								 document.getElementById("text2104").innerHTML = "　　" + data_str[1];
							 },     
							 failure : function() {        
								 Ext.Msg.alert('错误', '服务器出现错误请稍后再试！');     
							 }  
						  });
					}
				});
				
				 var valueType_radio = new Ext.form.RadioGroup({
                       id:'valueType_radio_id',
					   style:'width:100px; display: block;text-align:left;line-height:22px;',
					   height:20,
					   width:90,
       				   fieldLabel : '查询类型',
                       columns : 2,
                       vertical :true,
                       items:[
                              {boxLabel:'周',inputValue:'fssy',name:'fvalueType', checked: true},
                              {boxLabel:'月',inputValue:'fszy',name:'fvalueType'}
                       ],
				       listeners : {
				        	'change' : function(rg, checked){
				        		valueType_radio.getEl().dom.readOnly = checked.getGroupValue() == 'yes' ? false : true;
					   }}
			    });
			
					
			    var panel = new Ext.Panel({
			    	region: "center",
					layout:'fit',
					border : true,
					margins:'0 5 0 0',
					tbar : [ '开始日期：', b_date, '-', '截止日期：',e_date, '-', '统计类型：', valueType_radio, '-',btn_search_chart ],
					items : [ detailsPanel]
				});
				
				var viewport = new Ext.Viewport({
					layout : 'border',
					items : [ panel ]
				});
			
			});
			
</script>


</html>